package Dao.Impl;

import Bean.Manager;
import Bean.User;
import Dao.ManageDao;
import Utils.DBHelp;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class ManageDaoImpl implements ManageDao {
    @Override
    public Manager LoginManager(String name,String passWord) {
        String sql = "select * from Manager where username = ? and password =MD5(?);";
        QueryRunner queryRunner = new QueryRunner();
        Manager query = null;
        try {
            query = queryRunner.query(DBHelp.getConnection(), sql, new BeanHandler<>(Manager.class),name,passWord);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
        }
        return query;
    }
}
